<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>show time</title>
<meta name="description" content="">
<meta name="keywords" content="">
<link href="" rel="stylesheet">
<script type="text/javascript">
	show_time();
	
	function show_time() {
		now_time = setInterval('start_time()', 1000);
	}

	function start_time() {
		var span = document.getElementById('display_time');
		var now = new Date();
		// localtime = now.toString();
		// utctime = now.toUTCString();
		hours = now.getHours();
		minutes = now.getMinutes();
		seconds = now.getSeconds();
		milliseconds = now.getMilliseconds();

		if (hours < 10) {
			hours = '0' + hours;
		} else if (minutes < 10) {
			minutes = '0' + minutes;
		} else if (seconds < 10) {
			seconds = '0' + seconds;
		}

		// document.write('local time: ' + localtime + '<br/>');
		// document.write('UTC time: ' + utctime + '<br/>');
		// document.write('time: ' + hours + ':' + minutes + ':' + seconds + ':' + milliseconds + '<br/>');
		span.innerHTML = hours + ':' + minutes + ':' + seconds + ':' + milliseconds;
	}

	function stop_time() {
		clearInterval(now_time);
	}

	document.getElementById('start').addEventListener('click',show_time,false);
	document.getElementById('stop').addEventListener('click',stop_time,false);
</script>
</head>
<body>
	<h1>now time: <span id="display_time"></span></h1>
	<input type="button" id="start" value="开始" />
	<input type="button" id="stop" value="结束" />
</body>
</html>